package com.qf.pojo;

import com.fasterxml.jackson.annotation.JsonFormat;//POST  form表单中 application/json 用于发送数据JSON串
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.qf.custom.MySerializer;
import org.springframework.format.annotation.DateTimeFormat;//?birthday  POST form表单中 application/x-www-form-urlencoded

import java.util.Date;

@JsonInclude(value = JsonInclude.Include.NON_EMPTY) //null值  空值  长度为0 不输出
public class User {

    //成员变量 ： id   POJO对象中成员变量 必须是驼峰 不能有_  -  表 _
    @JsonProperty(value = "new_id")
    private Integer id;

    @JsonIgnore//JSON串转对象的时候 忽略掉此成员变量
    private String name;

    private String password;

    private String sex;

    //日期格式
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date birthday;
    private Date registTime;
    //工资  @RequestBody接收不起作用   @ResponseBody响应的时候起作用
    @JsonSerialize(using = MySerializer.class)
    private Double salary;//在输出此属性时，使用MySerializer输出


    public Double getSalary() {
        return salary;
    }

    public void setSalary(Double salary) {
        this.salary = salary;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public Date getBirthday() {
        return birthday;
    }

    public void setBirthday(Date birthday) {
        this.birthday = birthday;
    }

    public Date getRegistTime() {
        return registTime;
    }

    public void setRegistTime(Date registTime) {
        this.registTime = registTime;
    }

    @Override
    public String toString() {
        return "User{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", password='" + password + '\'' +
                ", sex='" + sex + '\'' +
                ", birthday=" + birthday +
                ", registTime=" + registTime +
                ", salary=" + salary +
                '}';
    }
}